package com.sanyang.pda.dialog;

import android.content.Context;
import android.text.InputType;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;

import com.wangshen.base.dialog.base.BaseDialog;
import com.wangshen.projectbase.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class InputDialog extends BaseDialog {
    @BindView(R.id.fl_back)
    FrameLayout flBack;
    @BindView(R.id.et_password)
    EditText etPassword;
    @BindView(R.id.tv_queren)
    TextView tvQueren;
    private OnDialogClick onDialogClick;
    public InputDialog(@NonNull Context context, OnDialogClick onDialogClick) {
        super(context);
        this.onDialogClick=onDialogClick;
    }

    @Override
    public void initView() {
        ButterKnife.bind(this);
    }

    @Override
    public void initData() {

    }

    public void showNum() {
        super.show();
        etPassword.setHint("请输入数量");
        etPassword.setInputType(InputType.TYPE_CLASS_NUMBER);
    }


    public void show(String name) {
        super.show();
        etPassword.setHint(name);
    }

    @Override
    public int getView() {
        return R.layout.dialog_input;
    }

    @OnClick({R.id.fl_back, R.id.tv_queren})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.fl_back:
                dismiss();
                break;
            case R.id.tv_queren:
                if (TextUtils.isEmpty(etPassword.getText().toString())){
                    Toast.makeText(getContext(), "请输入质检员名称", Toast.LENGTH_SHORT).show();
                    return;
                }
                if (onDialogClick != null){
                    dismiss();
                    onDialogClick.onQueren(etPassword.getText().toString());
                }
                break;
        }
    }
    public static interface OnDialogClick{
        void onQueren(String content);
    }
}